//
//  StoreOrderViewController.m
//  OrderFood
//
//  Created by xiaofang wang on 2018/10/24.
//  Copyright © 2018年 zhiyuan. All rights reserved.
//

#import "StoreOrderViewController.h"
#import "BillCell.h"
#import "ListSelectView.h"
@interface StoreOrderViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *StoreOrderTableView;
@property(nonatomic,strong)UILabel *allInComeLb;
@property(nonatomic,strong)UILabel *storeNameLb;
@property(nonatomic,strong)UIButton *bottomBtn;

@end

@implementation StoreOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.name = @"门店订单";
    
    // 初始化UI
    [self setupUI];
    
}

// 初始化UI
- (void)setupUI{
    // 初始化TableView
    [self loadTableViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-SafeAreaTopHeight-50) tableViewStyle:UITableViewStylePlain refreshStyle:LSRefreshTypeDefault];
    self.mytableview.delegate = self;
    self.mytableview.dataSource = self;
    [self ls_headerBeginRefreshing];
    
    //底部
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-SafeAreaTopHeight-50, SCREEN_WIDTH, 50)];
    footerView.backgroundColor = WHITECOLOR;
    [self.view addSubview:footerView];
    [QTTools tool_addLineWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 1) superView:footerView];
    
    UILabel *allInComeLb = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH-127, 50)];
    allInComeLb.font = FONT(17);
    [footerView addSubview:allInComeLb];
    self.allInComeLb = allInComeLb;
    NSAttributedString *allStr = [QTTools getStrWithAllStr:[NSString stringWithFormat:@"%@%@",NSLocalizedString(@"zongshouru", nil),@"￥180.50"] rangeStr:@"￥180.50" color:themeColor font:17];
    allInComeLb.attributedText = allStr;
    
    self.storeNameLb = [[UILabel alloc] initWithFrame:CGRectMake(15, 30, self.allInComeLb.mh_width, 15)];
    self.storeNameLb.font = FONT(12);
    self.storeNameLb.text = [NSString stringWithFormat:@"(%@%@)",NSLocalizedString(@"shangjiaomendian", nil),@"西湖银泰店"];
    [footerView addSubview:self.storeNameLb];
    self.storeNameLb.hidden = YES;
    
    
    UIButton *hindInBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    hindInBtn.frame = CGRectMake(SCREEN_WIDTH-112, 0, 112, 50);
    hindInBtn.backgroundColor = themeColor;
    [footerView addSubview:hindInBtn];
    [hindInBtn setTitle:NSLocalizedString(@"lijishangjiao", nil) forState:UIControlStateNormal];
    [hindInBtn setTitleColor:WHITECOLOR forState:UIControlStateNormal];
    [hindInBtn addTarget:self action:@selector(hindInAction:) forControlEvents:UIControlEventTouchUpInside];
    self.bottomBtn = hindInBtn;
}

- (void)requestNewData{
    [self ls_headerEndRefreshing];
}
- (void)requestMoreData{
    [self ls_footerEndRefreshing];
}

//立即上交
-(void)hindInAction:(UIButton *)sender{
    ListSelectView *listView = [[ListSelectView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) title:@"上交门店" dataAry:@[@"西湖银泰店",@"下沙银泰店",@"外婆家",@"新白鹿店",@"西湖银泰店",@"下沙银泰店",@"外婆家",@"新白鹿店"]];
    [self.navigationController.view addSubview:listView];
    WeakObj(self)
    listView.selectBlock = ^(NSString *storeName) {
        [weakself setSubUIWithName:storeName];
    };
    
}
-(void)setSubUIWithName:(NSString *)storeName{
    self.storeNameLb.hidden = NO;
    self.storeNameLb.text = [NSString stringWithFormat:@"(%@%@)",NSLocalizedString(@"shangjiaomendian", nil),storeName];
    CGRect frame = self.allInComeLb.frame;
    frame.origin.y = 5;
    frame.size.height = 25;
    self.allInComeLb.frame = frame;
    self.bottomBtn.backgroundColor = RGBHex(0xfd7777);
    [self.bottomBtn setTitle:NSLocalizedString(@"mendianquerenzhong", nil) forState:UIControlStateNormal];
   
}
#pragma mark - Table view data source


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"BillCellId";
    BillCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[BillCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    cell.moneyLb.text = [NSString stringWithFormat:@"%@%@",@"12:58",NSLocalizedString(@"songda", nil)];
    cell.moneyLb.textColor = BLACKCOLOR;
    cell.moneyLb.font = FONT(14);
    cell.sendedtimeLb.hidden = YES;
    NSAttributedString *receiveStr = [QTTools getStrWithAllStr:[NSString stringWithFormat:@"%@%@",NSLocalizedString(@"yishou", nil),@"￥38.0"] rangeStr:@"￥38.0" color:themeColor font:14];
    cell.alreadyReceiveLb.attributedText = receiveStr;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 260;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
